package com.order_system.controller;


import com.order_system.constants.Code;
import com.order_system.entity.ResModel;
import com.order_system.service.ShopCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 李阳
 * @since 2023-01-06
 */
@RestController
@RequestMapping("/api/shop/car")
public class ShopCarController {

    @Autowired
    private ShopCarService shopCarService;

    /**
     * 加入购物车
     * @param ids 商品id集合
     * @return
     */
    @PostMapping(value = "/add",produces = "application/json")
    public ResModel add(@RequestBody List<Integer> ids){
        return shopCarService.add(ids);
    }

    /**
     * 查询购物车列表
     * @return
     */
    @GetMapping("/list")
    public ResModel list(){
        return ResModel.success(Code.SUCCESS,shopCarService.list());
    }

}

